package com.aipp.mall.common.redis;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @author Administrator
 */
@Service
@Slf4j
public class RedisService {

    @Resource
    private RedisCache redisCache;

    public String getAddressList() {
        String key = RedisKeys.ADDRESS_LIST_KEY;
        return redisCache.getCacheObject(key);
    }

    public void setAddressList(String list) {
        String key = RedisKeys.ADDRESS_LIST_KEY;
        redisCache.setCacheObject(key, list);
    }

    public String getWechatToken() {
        return redisCache.getCacheObject(RedisKeys.WECHAT_ACCESS_TOKEN);
    }

    public void setWechatToken(String token) {
        redisCache.setCacheObject(RedisKeys.WECHAT_ACCESS_TOKEN, token, 100, TimeUnit.MINUTES);
    }

    interface RedisKeys {
        String ADDRESS_LIST_KEY = "ADDRESS_LIST_KEY_";
        String WECHAT_ACCESS_TOKEN = "WECHAT_ACCESS_TOKEN_";
    }

}
